import request from '@/utils/request'
import { method } from 'lodash'

export function listRole (data) {
  return request({
    url: `/role/page?current=${data.current}&size=${data.size}`,
    method: 'post',
    data
  })
}

export function createRole (data) {
  return request({
    url: '/role/',
    method: 'post',
    data
  })
}

export function readRole (data) {
  return request({
    url: '/role/read',
    method: 'get',
    data
  })
}

export function updateRole (data) {
  return request({
    url: `/role/`,
    method: 'put',
    data
  })
}

export function deleteRole (roleId) {
  return request({
    url: `/role/${roleId}`,
    method: 'post'
  })
}

export function getPermission (roleId) {
  return request({
    url: `/permission/role-menu/relation/${roleId}`,
    method: 'get'
  })
}

export function updatePermission (data) {
  return request({
    url: '/permission/role-menu/bind',
    method: 'post',
    data
  })
}

export function roleOptions (query) {
  return request({
    url: '/role/list',
    method: 'get',
    params: query
  })
}

// 权限

export function permissionCurrentUser () {
  return request({
    url: '/permission/current-user',
    method: 'get'
  })
}
